透過 Discord Bot,你可以在手機或任何裝置上用 Discord 傳訊息給 Claude Code,讓它幫你處理專案任務。
Windows(PowerShell):
powershell -c "irm bun.sh/install.ps1 | iex"
安裝完成後重新開啟 PowerShell。
Mac / Linux(Terminal):
curl -fsSL https://bun.sh/install | bash
安裝完成後重新開啟 Terminal。
重設權杖,複製權杖bot、applications.commands在 Claude Code 對話中輸入:
/plugin install discord@claude-plugins-official
或是在 /plugin 後搜尋 discord
Install for you安裝後 重啟 claude
在 Claude Code 對話中輸入(替換為你的 Token):
/configure 你的BotToken
這會將 Token 寫入 ~/.claude/channels/discord/.env。
ex:
DISCORD_BOT_TOKEN=MTQ4NDYyMjQzMTQ2MDEzNDk4Mg.GqcE7R.l2TqV4uCYcmOgsrBcoShz7a8RoHv-JZ9ztdu1w
claude --channels plugin:discord@claude-plugins-official
看到以下訊息代表成功:
Listening for channel messages from: plugin:discord@claude-plugins-official
/access pair 配對碼
設定完成
每次啟動 Claude Code 並連接 Discord,原本需要輸入這串完整指令:
claude --dangerously-skip-permissions --channels plugin:discord@claude-plugins-official
為了不用每次都輸入落落長的指令,在 PowerShell 設定一個簡短的 function。
找到你的 PowerShell profile 路徑:
$PROFILE
用記事本開啟:
notepad $PROFILE
在檔案最後加入這行並儲存:
function claude-discord { claude --dangerously-skip-permissions --channels plugin:discord@claude-plugins-official }
說明:
--dangerously-skip-permissions # 表示要用 bypass permissions mode 啟動 claude
--channels plugin:discord@claude-plugins-official # 表示啟動時要監聽 discord 的訊息
重新開啟 PowerShell 讓設定生效。
之後只需輸入
claude-discord就等同於完整指令。
預設只有 DM 有效。如果你想在 Discord 伺服器的特定頻道裡操控 Claude,需要額外設定。
1. 取得頻道 ID
開啟 Discord 左下角「使用者設定 → 進階 → 開發者模式」儲存後,對想使用的頻道按右鍵 → 複製頻道 ID。
2. 將該頻道加入允許清單
在 Claude Code 對話中輸入:
/access group add 頻道ID
3. 在頻道裡 @提及 Bot 來觸發
@你的Bot名稱 幫我做某件事
預設需要 @mention 才會觸發。如果不想每次都 @,可以改用:
/daccess group add 頻道ID --no-mention
如果想移除 claude-discord 指令:
notepad $PROFILE
刪除剛才加入的 function claude-discord { ... } 那一行,存檔後重開 PowerShell 即可。
claude-discord(或完整指令)才會開啟 Discord 監聽